package com.smh.a01DateDemo1;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateDemo3 {
    public static void main(String[] args) throws ParseException {
        //无参
        SimpleDateFormat sdf = new SimpleDateFormat();
        Date date = new Date();
        System.out.println(sdf.format(date));
        //有参
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        System.out.println(sdf2.format(date));

        SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss EE");
        System.out.println(sdf3.format(date));


        //将字符串转化为时间
        String s = "2023-11-11 11:11:11";
        SimpleDateFormat sdf4  = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1 = sdf4.parse(s);
        System.out.println(sdf4.format(date1));
        System.out.println(date1.getTime());


    }
}
